TabControl.inherit("Control");

function TabControl(node){
	this.Control(node);
	
	this.SELECTED_CLASS = "smalltabselected";
	this.NOT_SELECTED_CLASS = "smalltab";
	this.table = node;	
	this.hidden = document.getElementById(this.properties.getString("hiddenId"));
	this.headerTable = document.getElementById(this.properties.getString("headerTableId"));
}

TabControl.prototype.selectTab = function (index) {
    for (var i = 0; i<this.getTabCount(); i++) {
        var header = this.getHeader(i);
        if (!Utils.isDefined(header.className)||header.className=="") continue;
        header.className = (i==index?this.SELECTED_CLASS:this.NOT_SELECTED_CLASS);
        var tab = this.getTab(i);
        tab.style.display = (i==index?"":"none");
    }  
    this.hidden.value = index;  
}

TabControl.prototype.getHeader = function (index) {
    return this.headerTable.rows[0].cells[index];
}

TabControl.prototype.getTab = function (index) {
    return this.table.rows[index+1];
}

TabControl.prototype.getTabCount = function () {
    return this.headerTable.rows[0].cells.length;
} 

TabControl.prototype.getSelectedTabIndex = function () {
    return this.hidden.value;
} 